package org.gp.demo.net;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;

public class SocketDemo {
	public static void main(String[] args) {
		try {
			// Socket socket = new Socket("newweb.chinanpo.gov.cn", 8001);
			// socket.setSoTimeout(1000 * 10);
			Socket socket = new Socket();
			socket.connect(
					new InetSocketAddress("newweb.chinanpo.gov.cn", 8001),
					1000 * 10);
			InputStream is = socket.getInputStream();

			Scanner sc = new Scanner(is);
			while (sc.hasNextLine()) {
				System.out.println(sc.nextLine());
			}
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
